<?php
/**
 * Template Name: Portfolio
 **/ 
get_header(); 
if(have_posts()) : while(have_posts()) : the_post(); ?>
<div class="portfolio-page">
    <?php
    $page_bg = get_field("background_image", get_the_ID());
    $bg_img = '';
    if(!empty($page_bg)) {
        $bg_img = 'style="background: url('.dynamic_url($page_bg['url']).') left center;background-size: 100%; background-repeat: no-repeat;"';
    } 
    ?>
    <div class="container"> <img src="<?php echo get_template_directory_uri()?>/assets/images/loader.gif" class="load-img"/>
        <div class="content-inner" <?php echo $bg_img; ?>>
        
            <div class="top-content talldark">
                <?php the_content(); ?>
            </div>
            
            <?php $detect = new Mobile_Detect; ?>
            <div class="categories <?php echo ( $detect->isMobile() || $detect->isTablet()) ? "mobile" : "desktop"; ?>" id="slider-categories">
            <?php
            $categories = get_categories(array( 
                'type'          => 'portfolio',
                'parent'        => 0,
                'orderby'       => 'id',
                'hide_empty'    => 0,
                'taxonomy'      => 'portfolio_category'
            ));
            if(!empty($categories)) : ?>
                <?php foreach($categories as $k => $v) : 
                    $color = get_field('main_color', 'portfolio_category_'.$v->term_id); 
                    $thumb_img = get_field('thumbnail_image', 'portfolio_category_'.$v->term_id);
                    $category_link = get_term_link($v, 'portfolio_category'); 
                    $deactive = get_field('deactive', 'portfolio_category_'.$v->term_id); ?>
                    
                    <div class="sliderus-item <?php echo ($deactive == 1) ? "deactive" : ""; ?>">
                        <a <?php echo ($deactive == 1) ? "" : 'href="'.dynamic_url($category_link).'"'?>>
                            <div class="img">
                                <img src="<?php echo dynamic_url($thumb_img['url']); ?>" alt="<?php _e($v->name);?>"/>
                            </div>
                            
                            <?php if($deactive == 1) : ?>
                                <div class="coming-soon">
                                    <p><?php _e("Coming soon...", THB_THEME_NAME); ?></p>
                                </div>
                            <?php endif; ?>
                            
                            <div class="text">
                                <h2>
                                    <span><?php _e($v->name);?></span>
                                    <?php if($deactive == 1) : ?>
                                        <span class="coming"><?php _e("Coming soon...", THB_THEME_NAME); ?></span>
                                    <?php endif; ?>
                                </h2>
                            </div>
                        </a>
                    </div>
                    
                    <?php /*<div class="category-item">
                        <div class="left">
                            <div class="category-name">
                                <h2><a href="<?php echo dynamic_url($category_link); ?>" style="color: <?php echo $color; ?>;"><?php _e($v->name);?></a></h2>
                            </div>
                        </div>
                        <div class="right">
                            <div class="thumb" style="background-color: <?php echo $color; ?>;">
                                <a href="<?php echo dynamic_url($category_link); ?>"><img src="<?php echo dynamic_url($thumb_img['url']); ?>" alt="<?php _e($v->name);?>"/></a>
                            </div>
                        </div>
                    </div>*/ ?>
                    
                <?php endforeach; ?>
            <?php endif; ?>
            </div>
            
            <div class="text-center bottom-content">
                <img src="<?php echo get_template_directory_uri()?>/assets/images/contact-roboto-logo.png" alt="Roboto Logo"/>
            </div>
        </div>
    </div>
</div>
<?php
endwhile; endif; 
get_footer(); ?>